from selenium import webdriver
from selenium.webdriver.common.by import By
import time

# 打开edge浏览器
driver = webdriver.Edge()
# driver = webdriver.Firefox()
# driver = webdriver.Chrome()
# 进入携程网站
driver.get('https://www.ctrip.com/')
# 下拉网页
driver.execute_script('window.scrollTo(0,1000)')
time.sleep(3)
# 使用class定位登录按钮
driver.find_element(By.CLASS_NAME, 'tl_nfes_home_header_login_not_frb4a').click()
time.sleep(2)
# 使用XPATH定位协议
driver.find_element(By.XPATH, '/html/body/div[1]/div[2]/div/div[2]/div[2]/div/div/div[1]/div[4]/div/div[1]/label').click()
time.sleep(2)
# 使用selector定位qq
driver.find_element(By.CSS_SELECTOR, '#bbz_accounts_pc_lg_box > div > div > div.lg_loginbox.lg_ercode > div.lg_weblogin > div.login-other > a.icon-qq').click()
driver.switch_to.window(driver.window_handles[-1])
time.sleep(10)
